import axios from 'axios';
import useAppStore from '@/store/modules/app';

export interface FileVo {
  contentType?: string;
  foreignId?: string;
  id: string;
  uid?: string;
  url?: string;
  name?: string;
  prefixPath?: string;
  previewFileUrl?: string;
  size?: 0;
  type?: string;
}

export interface UploadFileResponseVo {
  name: string;
  id: string;
}
export interface FileBase64Str {
  fileName: string;
  fileBase64String: string;
  mimeType: string;
  id: string;
}
export function uploadFiles(params: any) {
  return axios.post<UploadFileResponseVo>(`/tenant/file/upload`, params);
}
// 批量上传文件
export function uploadBatchFiles(params: any) {
  return axios.post<UploadFileResponseVo[]>(`/file/uploadBatch`, params);
}
export function getFile(id?: string) {
  const str = useAppStore();
  return id ? `${str.appBaseUrl}/tenant/file/getFile?fileId=${id}` : '';
}
export async function downLoadFile(id?: string) {
  const str = useAppStore();
  return id ? `${str.appBaseUrl}/tenant/file/download?id=${id}` : '';
}
export function getFileDetail(id: string) {
  return axios.get<FileBase64Str>(`/tenant/file/detail?id=${id}`);
}
